package com.rljk.config;

import com.rljk.common.interceptor.AppLoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * Author:   YASUO
 * Date:     2018/7/18 11:22
 * Description:
 */
//@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    //在拦截器中注入service时,报空指针.发现拦截器的加载时间在Spring上下文之前加载,,所以需要提前将拦截器注册到Spring上下文中
    @Autowired
    private AppLoginInterceptor appLoginInterceptor;


    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //这里可以添加多个拦截器
        registry.addInterceptor(appLoginInterceptor).addPathPatterns("/**").excludePathPatterns("/user/login","/home/**");
    }

}
